package com.dongdong.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.dongdong.utils.PayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PayConfig {
    @Autowired
    private PayUtils payUtils;

    @Bean
    public AlipayClient alipayClient(){
        AlipayClient alipayClient = new DefaultAlipayClient(
                payUtils.getServerUrl(),
                payUtils.getAppId(),
                payUtils.getPrivateKey(),
                payUtils.getFormat(),
                payUtils.getCharset(),
                payUtils.getAlipayPublicKey(),
                payUtils.getSignType());
        return alipayClient;
    }
}
